import React from 'react';
import { connect } from 'dva';
import { List, Icon, WhiteSpace, TextareaItem, DatePicker } from 'antd-mobile';
import jump from '../../../utils/jump';
import { ChildWrap } from '../../../components/layout';
import plus from '../../../assets/img/plus.svg';

const Item = List.Item;
/*
 * 新建病例讨论
 * */
function Create({ dispatch, discuss }) {
    const { tempDiscuss } = discuss;
    const back = (e) => {
        e.preventDefault();
        jump(dispatch)('home/discuss');
    };
    const addHandler = (e) => {
        e.preventDefault();
    };
    const changeDate = (v) => {
        tempDiscuss.startTime = v;
        dispatch({
            type: 'discuss/setState',
            payload: {
                tempDiscuss,
            },
        });
    };
    if (tempDiscuss) {
        return (
            <ChildWrap
                content="创建讨论"
                iconName="left"
                onLeftClick={back}
                rightContent={
                    <a onClick={addHandler}>添加</a>
                }
            >
                <List>
                    <DatePicker
                        className="forss"
                        mode="datetime"
                        onChange={changeDate}
                        value={tempDiscuss.startTime}
                    >
                        <Item
                            arrow="horizontal"
                            extra="尚未设置"
                        >
                            讨论时间
                        </Item>
                    </DatePicker>
                </List>
                <WhiteSpace size="lg"/>
                <List>
                    <Item
                        extra="尚未选择"
                        arrow="horizontal"
                    >
                        选择患者(病例)
                    </Item>
                </List>
                <WhiteSpace size="lg"/>
                <List>
                    <Item
                        extra={<Icon type={plus}/>}
                    >
                        邀请医生
                    </Item>
                </List>
                <WhiteSpace size="lg"/>
                <List>
                    <TextareaItem
                        title="讨论目的"
                        placeholder="点击下方按钮该输入框会获取光标"
                        data-seed="logId"
                        autoHeight
                    />
                </List>
            </ChildWrap>
        );
    }
    return (<div>初始化</div>);
}

function mapStateToProps({ discuss }) {
    return { discuss };
}

export default connect(mapStateToProps)(Create);
